package com.itheima.case2.dao;


import com.itheima.case2.pojo.po.User;
import com.itheima.case2.pojo.vo.AddUser;
import com.itheima.case2.pojo.vo.QueryPageBean;
import com.itheima.case2.pojo.vo.UpdateUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    //分页查询用户和对应角色信息，多表查询，使用映射文件
    List<User> selectUser(QueryPageBean queryPageBean);
    List<User> selectUser2(QueryPageBean queryPageBean);

    //获取总用户个数
//    @Select("select count(*) from t_user")
    Long findUserTotal(QueryPageBean queryPageBean);
    Long findUserTotal2(QueryPageBean queryPageBean);
    //更新用户表
    @Update("update t_user set username=#{username},email=#{email},password=#{password} where id=#{id}")
    void updateUserById(UpdateUser updateUser);

    //添加用户
    @Insert("insert into t_user values(null,#{username},#{password},null,#{email},now(),now())")
    void addUser(AddUser addUser);

    //获取最大id
    @Select("select max(id) from t_user")
    int getMaxById();

    //删除用户
    @Delete("delete from t_user where id=#{id}")
    void deleteUser(@Param("id") Integer id);

}
